Skip to content

Fix/fresh start#14

Open
juanfernandezgullermo wants to merge 1 commit into
evolution-foundation:developfrom
juanfernandezgullermo:fix/fresh_start
Open

Fix/fresh start#14
juanfernandezgullermo wants to merge 1 commit into
evolution-foundation:developfrom
juanfernandezgullermo:fix/fresh_start

Conversation

@juanfernandezgullermo

@juanfernandezgullermo juanfernandezgullermo commented Jun 16, 2026

Copy link
Copy Markdown

Description

Make idempotent Alembic migration for fresh start up

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • CI/CD
  • Refactor
  • Other: Fix for fresh start up

Service(s) Affected

  • Auth Service (evo-auth-service-community)
  • CRM Service (evo-ai-crm-community)
  • Frontend (evo-ai-frontend-community)
  • Processor (evo-ai-processor-community)
  • Core Service (evo-ai-core-service-community)
  • Root / Infrastructure (docker-compose, Makefile, CI/CD, docs)

Checklist

  • I have tested this locally
  • I have updated documentation (if applicable)
  • This does not introduce breaking changes
  • I have followed the Contributing Guidelines

Summary by Sourcery

Bug Fixes:

  • Prevent migration failures on fresh startup by creating the evo_processor_agent_memory table only if it does not already exist.

@sourcery-ai

sourcery-ai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Make the Alembic migration for creating the evo_processor_conversations_tokens table idempotent so it can safely run on fresh startup even if the table already exists.

Entity relationship diagram for idempotent evo_processor_conversations_tokens migration

erDiagram
    evo_core_agents {
        int id
    }

    evo_processor_conversations_tokens {
        int id
        int agent_id
        int total_tokens
        datetime created_at
    }

    evo_core_agents ||--o{ evo_processor_conversations_tokens : has
Loading

File-Level Changes

Change Details Files
Make the conversations tokens table creation migration idempotent.
  • Update the sa.Table creation in the Alembic upgrade() function to include the if_not_exists=True argument on the table definition
  • Ensure that re-running the migration on a database where the table already exists will no longer fail with a duplicate-table error
migrations/versions/26a14ac7025d_.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Double-check that if_not_exists=True is actually supported by the Alembic/SQLAlchemy versions in this project; if not, consider using a custom op.execute DDL statement or a conditional check for table existence instead.
  • Be aware that CREATE TABLE IF NOT EXISTS semantics are dialect-specific; if this service might run on multiple database backends, you may want to guard the migration with an explicit existence check rather than relying on the dialect’s IF NOT EXISTS support.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Double-check that `if_not_exists=True` is actually supported by the Alembic/SQLAlchemy versions in this project; if not, consider using a custom `op.execute` DDL statement or a conditional check for table existence instead.
- Be aware that `CREATE TABLE IF NOT EXISTS` semantics are dialect-specific; if this service might run on multiple database backends, you may want to guard the migration with an explicit existence check rather than relying on the dialect’s `IF NOT EXISTS` support.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@juanfernandezgullermo juanfernandezgullermo changed the title Fix idempotent migration Fix/fresh start Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant